//
//  CookCustomView.m
//  X-Touch2
//
//  Created by shengchao yang on 12-3-29.
//  Copyright (c) 2012年 foxhis. All rights reserved.
//

#import "CookCustomView.h"
#import "Singleton.h"
#import "FileManager.h"
#import "Common.h"
@implementation CookCustomView
@synthesize textViewMyCook;

- (id)initWithNibName:(NSString *)nibNameOrNil withObj:(NSString *)obj{
    cookStr = obj;
    self = [super initWithNibName:nibNameOrNil bundle:nil];
    if (self) {
        // Custom initialization
        [((UIButton *)[self.view viewWithTag:TagOfUIButton]) setTitle:TranslateStr(@"确定") forState:UIControlStateNormal];
        [textViewMyCook becomeFirstResponder];
    }
    return self;
}
- (IBAction)buttonClicked:(id)sender {
    if (AppSession.isAnimating) {
        MyNSLog(@"上一个动画还未完成...");
        return;
    }
    [AppSession playMusic:VoiceFile(@"clicked.caf")];
    NSInteger bid = [sender tag];
    if (bid == TagOfUIButton) {
        NSDictionary * infos = [NSDictionary dictionaryWithObjectsAndKeys:textViewMyCook.text,@"cookFromCustom", nil];
        postNWithInfos(@"SysMsg_CookSelectView_refreshLabelCook", nil, infos);
        
        NSString *SysMsg = [NSString stringWithFormat:@"SysMsg_MessageBoxBaseView_%@", self.nibName];
        postN(SysMsg);//关闭弹出窗口
    }
}

#pragma mark - View lifecycle
- (void)viewDidLoad{
    textViewMyCook.text = cookStr;
    [super viewDidLoad];
}

- (void)viewDidUnload{
    [self setTextViewMyCook:nil];
    [super viewDidUnload];
}
-(void)dealloc{
    MyNSLog(@"CookCustomView is deallocing");
    [textViewMyCook release];
    [super dealloc];
}
- (void)didReceiveMemoryWarning{
    [super didReceiveMemoryWarning];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

@end
